#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e9 + 5;

int n, m;
vector<int> c;

bool check(int mid) {
    ll need = 0;
    for (int i = 0; i < n; i++) {
        if (c[i] < mid) need += mid - c[i];
    }
    return need <= m && need <= mid;
}

void solve() {
    cin >> n >> m;
    c.resize(n);
    for (int i = 0; i < n; i++) cin >> c[i];
    int l = 0, r = N;
    while (l <= r) {
        int mid = l + (r - l) / 2;
        if (check(mid)) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout << r << endl;

    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}